package demo_0512;

import javax.swing.*;
import java.awt.*;

public class Test1 extends JPanel {
    private static final int width = 100;
    int[] Recttangle1 = {width,355};
    int[] Recttangle2 = {width,560};
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 36));
        g.drawString("销量", 500, 50);
        g.drawLine(100, 200, 1000, 200);
        g.drawString("600",20,200);
        g.drawLine(100, 400, 1000, 400);
        g.drawString("400",20,400);
        g.drawLine(100, 600, 1000, 600);
        g.drawString("200",20,600);
        g.drawLine(100, 800, 1000, 800);
        g.drawString("0",20,800);
        g.setColor(new Color(0, 64, 255, 255));
        g.fillRect(200,800 - Recttangle1[1],Recttangle1[0],Recttangle1[1]);
        g.setColor(new Color(255, 115, 0, 255));
        g.fillRect(600,800 - Recttangle2[1],Recttangle2[0],Recttangle2[1]);
    }
    public static void main(String[] args) {
        JFrame frame = new JFrame("My Drawing");
        frame.setBounds(200, 200, 1000, 1000);
        frame.setVisible(true);
        Test1 test1 = new Test1();
        frame.add(test1);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
